<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>美材帮</title>
  <link rel="icon" href="./favicon.ico">
  <script>
    function changeFavicon() {
      console.log('执行')
      document.title = '修改'
      let currentIcon = "./favicon2.ico"; //可通过后端动态获取名称
      let link = document.querySelector('link[rel*="icon"]');
      link.href = currentIcon;
    }
  </script>
</head>

<body>

  <button onclick="changeFavicon()">修改title</button>

</body>

</html>